public class Demo05 {

    public static void main(String[] args) {
        // 插入排序
        int[] nums = {2, 4, 19, 23, 0, -1, -4};
        for (int i = 1; i < nums.length; i++) {
            int current = nums[i];
            int prevIndex = i - 1;
            for (;prevIndex >=0  && nums[prevIndex] < current ; prevIndex--) {
                nums[prevIndex + 1] = nums[prevIndex];
            }
            nums[prevIndex + 1] = current;
        }

        for (int num : nums) {
            System.out.println(num);
        }
    }
}
